home *** CD-ROM | disk | FTP | other *** search
- class prop.pz1 extends MovieClip
- {
- var cq;
- var rq;
- var usedTimes;
- var usedTimesMax;
- var clockwise;
- var shapeSqc1;
- var shapeSqc2;
- var firstDrct;
- var answerR;
- var answerC;
- var aAgl;
- var aBtnNum;
- function pz1()
- {
- super();
- this.cq = 3;
- this.rq = 3;
- this.usedTimes = 0;
- this.usedTimesMax = 2;
- this.clockwise = true;
- this.shapeSqc1 = new Array();
- this.shapeSqc1.push({shape:"square",ranNum:0});
- this.shapeSqc1.push({shape:"triangle",ranNum:0});
- this.shapeSqc1.push({shape:"circle",ranNum:0});
- this.shapeSqc2 = new Array();
- this.shapeSqc2.push({shape:"square",ranNum:0});
- this.shapeSqc2.push({shape:"star",ranNum:0});
- this.shapeSqc2.push({shape:"circle",ranNum:0});
- this.resetMe();
- }
- function resetMe()
- {
- var _loc8_ = 0;
- while(_loc8_ < this.rq)
- {
- var _loc2_ = 0;
- while(_loc2_ < this.cq)
- {
- this["r" + _loc8_ + "c" + _loc2_].gotoAndStop("normal");
- this["r" + _loc8_ + "c" + _loc2_].ctt2._x = this["r" + _loc8_ + "c" + _loc2_].ctt2._y = 0;
- _loc2_ = _loc2_ + 1;
- }
- _loc8_ = _loc8_ + 1;
- }
- _loc8_ = 0;
- while(_loc8_ < 4)
- {
- this["btn" + _loc8_].ctt2._x = this["btn" + _loc8_].ctt2._y = 0;
- this["btn" + _loc8_].onPress = this.btnPrsW;
- _loc8_ = _loc8_ + 1;
- }
- var _loc12_ = false;
- this.clockwise = 1 * Math.random() <= 0.5 ? false : true;
- this.firstDrct = Math.floor(4 * Math.random());
- this.answerR = Math.floor(this.rq * Math.random());
- this.answerC = Math.floor(this.cq * Math.random());
- this["r" + this.answerR + "c" + this.answerC].gotoAndStop("tar");
- _loc8_ = 0;
- while(_loc8_ < this.rq)
- {
- this.shapeSqc1[_loc8_].ranNum = 1 * Math.random();
- this.shapeSqc2[_loc8_].ranNum = 1 * Math.random();
- _loc8_ = _loc8_ + 1;
- }
- this.shapeSqc1.sortOn("ranNum",Array.NUMERIC);
- this.shapeSqc2.sortOn("ranNum",Array.NUMERIC);
- _loc8_ = 0;
- while(_loc8_ < this.rq)
- {
- if(this.answerR != _loc8_ && !_loc12_)
- {
- _loc12_ = true;
- var _loc11_ = Math.floor(this.cq * Math.random());
- this["r" + _loc8_ + "c" + _loc11_].gotoAndStop("mask");
- }
- var _loc10_ = this.normalDeg((this.firstDrct + _loc8_) * 90);
- if(this.answerR == _loc8_)
- {
- this.aAgl = _loc10_;
- }
- var _loc13_ = Math.sin(_loc10_ * 3.141592653589793 / 180);
- var _loc14_ = Math.cos(_loc10_ * 3.141592653589793 / 180);
- _loc13_ = Math.abs(_loc13_) >= 0.0001 ? _loc13_ : 0;
- _loc14_ = Math.abs(_loc14_) >= 0.0001 ? _loc14_ : 0;
- _loc2_ = 0;
- while(_loc2_ < this.cq)
- {
- this["r" + _loc8_ + "c" + _loc2_].ctt1.gotoAndStop(this.shapeSqc1[_loc8_].shape);
- this["r" + _loc8_ + "c" + _loc2_].ctt2.gotoAndStop(this.shapeSqc2[_loc8_].shape);
- this["r" + _loc8_ + "c" + _loc2_].ctt2._x += 20 * _loc2_ * _loc14_;
- this["r" + _loc8_ + "c" + _loc2_].ctt2._y += 20 * _loc2_ * _loc13_;
- _loc2_ = _loc2_ + 1;
- }
- _loc8_ = _loc8_ + 1;
- }
- _loc8_ = 0;
- while(_loc8_ < 4)
- {
- this["btn" + _loc8_].ctt1.gotoAndStop(this.shapeSqc1[this.answerR].shape);
- this["btn" + _loc8_].ctt2.gotoAndStop(this.shapeSqc2[this.answerR].shape);
- _loc8_ = _loc8_ + 1;
- }
- var _loc3_ = new Array();
- _loc8_ = 0;
- while(_loc8_ < 4)
- {
- var _loc6_ = false;
- while(!_loc6_)
- {
- var _loc9_ = this.normalDeg(Math.floor(Math.random() * 4) * 90);
- var _loc7_ = 1 + Math.floor(Math.random() * 2);
- var _loc4_ = false;
- var _loc5_ = false;
- if(_loc9_ == this.aAgl && _loc7_ == this.answerC)
- {
- _loc5_ = true;
- }
- _loc2_ = 0;
- while(_loc2_ < _loc3_.length)
- {
- if(_loc3_[_loc2_].aglWrong == _loc9_ && _loc3_[_loc2_].cWrong == _loc7_)
- {
- _loc4_ = true;
- }
- _loc2_ = _loc2_ + 1;
- }
- if(!_loc4_ && !_loc5_)
- {
- _loc3_.push({aglWrong:_loc9_,cWrong:_loc7_});
- _loc6_ = true;
- }
- }
- _loc13_ = Math.sin(_loc9_ * 3.141592653589793 / 180);
- _loc14_ = Math.cos(_loc9_ * 3.141592653589793 / 180);
- _loc13_ = Math.abs(_loc13_) >= 0.0001 ? _loc13_ : 0;
- _loc14_ = Math.abs(_loc14_) >= 0.0001 ? _loc14_ : 0;
- this["btn" + _loc8_].ctt2._x += 20 * _loc7_ * _loc14_;
- this["btn" + _loc8_].ctt2._y += 20 * _loc7_ * _loc13_;
- _loc8_ = _loc8_ + 1;
- }
- this.aBtnNum = Math.floor(4 * Math.random());
- _loc13_ = Math.sin(this.aAgl * 3.141592653589793 / 180);
- _loc14_ = Math.cos(this.aAgl * 3.141592653589793 / 180);
- _loc13_ = Math.abs(_loc13_) >= 0.0001 ? _loc13_ : 0;
- _loc14_ = Math.abs(_loc14_) >= 0.0001 ? _loc14_ : 0;
- this["btn" + this.aBtnNum].ctt2._x = 20 * this.answerC * _loc14_;
- this["btn" + this.aBtnNum].ctt2._y = 20 * this.answerC * _loc13_;
- this["btn" + this.aBtnNum].onPress = this.btnPrsR;
- }
- function normalDeg(r)
- {
- if(r >= 180)
- {
- r -= 360;
- }
- if(r <= -180)
- {
- r += 360;
- }
- return r;
- }
- function btnPrsW()
- {
- this._parent.prsWrong();
- }
- function btnPrsR()
- {
- this._parent.prsRight();
- }
- function prsWrong()
- {
- this.usedTimes = this.usedTimes + 1;
- if(this.usedTimes > 2)
- {
- _global.scene.pwSource.gotoAndStop("broken");
- this._visible = false;
- }
- _global.ctn.sndCtrl.playSound("snd_pzWrong");
- this._visible = false;
- }
- function prsRight()
- {
- trace("choose right");
- _global.ctn.sndCtrl.playSound("snd_pzRight");
- _global.scene.pwSource.coverAni.play();
- if(!_global.scene.pzScoreOver)
- {
- _global.scene.pzScoreOver = true;
- _global.ctn.game.addScore(300,500,0,60);
- _global.ctn.game.addScore(45,Math.round(100 * (1 - this.usedTimes / this.usedTimesMax)),0,60);
- }
- this.unloadMovie();
- }
- }
-